<?php

namespace G4T\Form\Element;

class CaptchaElement extends \Zend_Form_Element_Captcha implements ElementInterface, TypeInterface
{

    public function init()
    {
        $uploadDir = dirname(APPLICATION_PATH) . \Zend_Registry::get('config')->captcha->image->dir;
        $fontDir = dirname(APPLICATION_PATH) . \Zend_Registry::get('config')->captcha->font->path;
        $options = array('label' => 'Write the chars to the field',
            'captcha' => array(
                'captcha' => 'Image',
                'wordLen' => 6,
                'timeout' => 300,
                'font' => $fontDir,
                'imgDir' => $uploadDir,
                'imgUrl' => preg_replace('/.*public/', '', $uploadDir),
            ));
        $this->setOptions($options);

    }

    public function setParams(array $params)
    {
        // TODO: Implement setParams() method.
    }

    /**
     * Текстовое название типа для jqgrid.
     *
     */
    public function getFormElementType()
    {
        return "text";
    }
}
